﻿using FB.Providers.EmployeeInfo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace FB.Providers
{
    public static class DepartmentManager
    {
    //    public static EmployeeInfoUnit EmployeeInfoUnit
    //    {
    //        get
    //        {
    //            var EF = AspNetEmployeeInfoProviderManager.Default as EFEmployeeInfoProvider;
    //            if (null != EF)
    //            {
    //                return EF.GetEmployeeInfoUnit();
    //            }
    //            return null;
    //        }
    //    }

    //    public static Department GetDepartment(string DEPTCode)
    //    {
    //        EmployeeInfoUnit infounit = EmployeeInfoUnit;
    //        var query = infounit.DepartmentRepository.Get(t => t.DEPTCode == DEPTCode, null, "Company,ParentDepartment");
    //        return query.FirstOrDefault() ;
            
    //    }


    //    public static List<Department> GetAllDepartments()
    //    {
    //        EmployeeInfoUnit infounit = EmployeeInfoUnit;
    //        return infounit.DepartmentRepository.Get(null, null, "Company,ParentDepartment").ToList();
            
    //    }

    //    public static List<Department> FindDepartments(Expression<Func<Department, bool>> filter = null)
    //    {
    //        EmployeeInfoUnit infounit = EmployeeInfoUnit;
    //        return infounit.DepartmentRepository.Get(filter, null, "Company,ParentDepartment").ToList();
            
    //    }
    //    public static List<Department> FindDepartments(Expression<Func<Department, bool>> filter = null,
    //        Func<IQueryable<Department>, IOrderedQueryable<Department>> orderBy = null, string includeProperties = "")
    //    {
    //        EmployeeInfoUnit infounit = EmployeeInfoUnit;
    //        return infounit.DepartmentRepository.Get(filter, orderBy, includeProperties).ToList(); 
    //    }

    //    public static Department CreateDepartment(Department department)
    //    {
    //        EmployeeInfoUnit infounit = EmployeeInfoUnit;
    //        Department dept = infounit.DepartmentRepository.Insert(department);
    //        infounit.DepartmentRepository.SaveChanges();
    //        return dept;  
    //    }

    //    public static void UpdateDepartment(Department department)
    //    {
    //        EmployeeInfoUnit infounit = EmployeeInfoUnit;
    //        infounit.DepartmentRepository.Update(department);
    //        infounit.DepartmentRepository.SaveChanges(); 
    //    }

    //    public static void DeleteDepartment(string DEPTCode)
    //    {
    //        EmployeeInfoUnit infounit = EmployeeInfoUnit;
    //        infounit.DepartmentRepository.Delete(DEPTCode);
    //        infounit.DepartmentRepository.SaveChanges(); 
            
    //    }

    //    public static List<Department> FindDepartments(
    //       Expression<Func<Department, bool>> filter,
    //       Func<IQueryable<Department>, IOrderedQueryable<Department>> orderBy,
    //       int pageIndex, int pageSize, out int totalRecords)
    //    {
    //        EmployeeInfoUnit infounit = EmployeeInfoUnit;
    //        return infounit.DepartmentRepository.GetPagedList(filter, orderBy, pageIndex, pageSize, out totalRecords, "Company,ParentDepartment").ToList();

    //    }
    }
}
